package com.iqiyi.pps.epg.core.infrastructure.context;

/**
 * Created by IntelliJ IDEA.
 * User: lishunlong
 * Date: 12-6-25
 * Time: 下午5:51
 * To change this template use File | Settings | File Templates.
 */
public class UserContext {
    private static ThreadLocal<UserContext> threadLocal = new ThreadLocal<UserContext>();
    private String id = "-1";
    private String name = "none";
    private String ip = "";
    private String transId = "";

    public static UserContext getContext() {
        UserContext userContext = threadLocal.get();
        if(userContext == null) {
            userContext = new UserContext();
            threadLocal.set(userContext);
        }
        return userContext;
    }

    public static void cleanupContext() {
        threadLocal.set(null);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getTransId() {
        return transId;
    }

    public void setTransId(String transId) {
        this.transId = transId;
    }
}
